package com.gavin.book.model;

import com.gavin.book.enums.ResultCodeEnum;
import lombok.Data;

@Data
public class Result<T>{
    private ResultCodeEnum code;//-1未登入 200正常 -2出错
    private String errMsg;
    private T data;

    public static <T> Result sucess(T data){
        Result result=new Result();
        result.setCode(ResultCodeEnum.SUCCESS);
        result.setErrMsg("");
        result.setData(data);
        return result;
    }

    public static <T> Result fail(String errMsg,T data){
        Result result=new Result();
        result.setCode(ResultCodeEnum.FAIL);
        result.setErrMsg(errMsg);
        result.setData(data);
        return result;
    }
    public static <T> Result unlogin(){
        Result result=new Result();
        result.setCode(ResultCodeEnum.UNLOGIN);
        result.setErrMsg("用户未登录");
        return result;
    }
}
